﻿using UnityEngine;

using System.Collections;
using System;

namespace calc
{
    public class OperationAdd : Operation
    {
        public override double getResult()
        {
            
            double result = numA + numB;
            return result;
        }
    }

    public class OperationSub : Operation
    {
        public override double getResult()
        {
            double result = numA - numB;
            return result;
        }
    }

    public class OperationMul : Operation
    {
        public override double getResult()
        {
            double result = numA * numB;
            return result;
        }
    }

    public class OperationDiv : Operation
    {
        public override double getResult()
        {

            if(numB != 0)
            {
                double result = numA + numB;
                return result;

            }
            else
            {
                return 0;
            }
        }
    }

    public class OperationQuyu : Operation
    {
        public override double getResult()
        {

            double result = numA % numB;
            return result;
        }
    }

    public class OperationTan : Operation
    {
        public override double getResult()
        {

            double result = Math.Tan(numA);
            return result;
        }
    }

    public class OperationSin : Operation
    {
        public override double getResult()
        {

            double result = Math.Sin(numA);
            return result;
        }
    }

    public class OperationCos : Operation
    {
        public override double getResult()
        {

            double result = Math.Cos(numA);
            return result;
        }
    }

    public class OperationLn : Operation
    {
        public override double getResult()
        {

            double result = Math.Log(numA,Math.E);
            return result;
        }
    }

    public class OperationJieCheng : Operation
    {
        public double fact(double n)
        {
            if (n == 1 || n == 0)
                return 1;
            else
                return n * fact(n - 1);
        }

        public override double getResult()
        {
            return fact(numA);
        }
    }

    public class Operationx2 : Operation
    {
        public override double getResult()
        {

            double result = numA * numA;
            return result;
        }
    }

    public class Operationx3 : Operation
    {
        public override double getResult()
        {

            double result = numA * numA * numA;
            return result;
        }
    }

    public class OperationLog : Operation
    {
        public override double getResult()
        {

            double result = Math.Log(numA);
            return result;
        }
    }

    public class OperationXfenzhi1 : Operation
    {
        public override double getResult()
        {

            double result = 1 / numA;
            return result;
        }
    }

    public class OperationPi: Operation
    {
        public override double getResult()
        {

            double result = Math.PI;
            return result;
        }
    }
}


